package my.study.demo.proxy.client;

import java.util.Scanner;

public class Test02 {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String mm = sc.nextLine();

        String md = sc.nextLine();

        String[] mmArr = mm.split(",");

        String[] mdArr = md.split(",");


        if(mmArr.length == 0 || mdArr.length == 0) {
            System.out.println("not found2");

        }else {
            String finalResult = "";
            for(String mmd : mdArr){

                for(String mmm : mmArr) {
                    if(ifOk(mmd, mmm)) {
                        finalResult = finalResult + mmd + ",";
                    }
                }
            }
            if("".equals(finalResult)) {
                System.out.println("not found1");
            }else {
                System.out.println(finalResult.substring(0, finalResult.length() -1 ));
            }
        }


    }

    //b是否变换后和a一样
    public static boolean ifOk(String a, String b) {
        if(a.equals(b)) {
            return true;
        }
        char[] aArr = a.toCharArray();
        char[] bArr = b.toCharArray();
//        List aList = Arrays.asList(a.toCharArray());
//        List bList = Arrays.asList(b.toCharArray());

        int flag = 0;


        for(char charA : aArr) {
           for(char charB : bArr) {
               if(charA == charB) {
                   flag = 1;
                   break;
               }
           }
            if(flag == 0) {
                return false;
            }else {
                flag = 0;
            }

        }
        for(char charB : bArr) {
            for(char charA : aArr) {
                if(charA == charB) {
                    flag = 1;
                    break;
                }
            }
            if(flag == 0) {
                return false;
            }else {
                flag = 0;
            }
        }
        return true;
    }
}
